import GoogleTranslate from "@google-cloud/translate";
import credentials from "./sternelee-27c091bbed32.json";

const projectId = "sternelee";
const gTranslate = new GoogleTranslate.v2.Translate({
  projectId,
  credentials,
});

const translate = async (text) => {
  if (text.length < 1) return text;
  const target = "zh";
  const [translation] = await gTranslate.translate(text, target);
  return translation;
}

export default translate
